package jvm;

import java.util.ArrayList;

public class TestClassLoader03 {
    public static void doMethod01(){
        ClassLoader loader = ClassLoader.getSystemClassLoader();//获取类系统加载器
        System.out.println(loader);//AppClassLoader
        System.out.println(loader.getParent());//ExtClassLoader
        System.out.println(loader.getParent().getParent());//null(BootStrapClassLoader)
    }
    public static void doMethod02(){
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        System.out.println(loader);
        System.out.println(loader.getParent());
        System.out.println(loader.getParent().getParent());
    }

    public static void doMethod03() throws ClassNotFoundException{
        System.out.println("ClassLoader of this class:"
                +TestClassLoader03.class.getClassLoader());//AppClassLoader
        System.out.println("ClassLoader of Object:"
                + Object.class.getClassLoader());//null(BootStrapClassLoader)
        System.out.println("ClassLoader of ArrayList:"
                + ArrayList.class.getClassLoader());//null(BootStrapClassLoader)
    }

    public static void main(String[] args) throws ClassNotFoundException {
        doMethod01();
        doMethod02();
        doMethod03();
    }

}
